# 对文件进行过滤
# 1.根据结果进行结果过滤


'''
过滤文件 将位姿标定错误的文件剔除
'''

import os
import open3d as o3d
import numpy as np
import random
import json

import sys
import shutil
from tqdm import tqdm


# ''' 进行数据集的划分 '''筛选 文件
poses_img_dir = r"E:\pose\datasets\april\results_halcon_img"

source_dir_april_pose = r"E:\pose\datasets\april\offset_pose_april"
poses_matrx_dir = r"E:\pose\datasets\april\poses-martix"
source_dir_april_rgb =r'E:\pose\datasets\april\rgb'

#todo:修改为自己的路径
result_pose_halcon_dir= r"E:\pose\datasets\obj_ac\obj_000000\pose_halcon"
result_pose_april_dir= r"E:\pose\datasets\obj_ac\obj_000000\pose_april"
dis_dir_rgb =r'E:\pose\datasets\obj_ac\obj_000000\rgb'


for idx,filename in tqdm(enumerate(os.listdir(poses_img_dir))):# .img
    file_idx = int(filename.split('.')[0])
    shutil.copyfile(os.path.join(source_dir_april_pose,f"{file_idx}.txt"),os.path.join(result_pose_april_dir,f"{idx}.txt"))
    shutil.copyfile(os.path.join(poses_matrx_dir,f"{file_idx}.txt"),os.path.join(result_pose_halcon_dir,f"{idx}.txt"))
    shutil.copyfile(os.path.join(source_dir_april_rgb,f"{file_idx}.jpg"),os.path.join(dis_dir_rgb,f"{idx}.jpg"))
    